import { Component } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import * as actions from '../../actions/index'
import Top from './Top'
import List from './List'

class HomeList extends Component {

    componentDidMount() {
        if(!this.props.list || !this.props.list.length) {
            this.props.get_List()
        }
    }

    // detele(index){
    //     this.props.detele(index)
    // }

    render() { 
        let { list } = this.props
        return (
            <div>
                <Top/>
                <List list={list} />
            </div>
        )
    }
}

let mapStateToProps = ({homeReducer}) => {
    return {
        ...homeReducer
    }
}

let mapDispatchToProps = (dispatch) => bindActionCreators(actions, dispatch)
 
export default connect(mapStateToProps, mapDispatchToProps)(HomeList)